﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.Configuration.Install;
using System.Reflection;

namespace Service
{
	static class Program
	{
		static void Main(string[] args)
		{
			if (Environment.UserInteractive)
			{
				var parameter = string.Concat(args);
				switch (parameter)
				{
					case "--install":
						ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });
						break;
					case "--uninstall":
						ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });
						break;
				}
			}
			else
			{
				var servicesToRun = new ServiceBase[] 
				{ 
					new DomainAtHomeService() 
				};
				ServiceBase.Run(servicesToRun);
			}
		}
	}
}
